import unittest
from books_dedupe import extract_geo, extract_d1, extract_d2, extract_phase


class MyTestCase(unittest.TestCase):
    def test_extract_1(self):
        s = '中共霍山党史大事记1919·5-1999·12'
        self.assertEqual('霍山', extract_geo(s))
        self.assertEqual('1919', extract_d1(s))
        self.assertEqual('1999', extract_d2(s))

    def test_extract_2(self):
        s = '1919-1949中共六安地区党史大事记'
        self.assertEqual('六安', extract_geo(s))
        self.assertEqual('1919', extract_d1(s))
        self.assertEqual('1949', extract_d2(s))

    def test_extract_3(self):
        s = '保定党史大事记1919-1949'
        self.assertEqual('保定', extract_geo(s))
        self.assertEqual('1919', extract_d1(s))
        self.assertEqual('1949', extract_d2(s))

    def test_extract_4(self):
        s = '大同市解放后党史大事记1949-1985'
        self.assertEqual('大同', extract_geo(s))
        self.assertEqual('1949', extract_d1(s))
        self.assertEqual('1985', extract_d2(s))

    def test_extract_5(self):
        s = '福建地方党史大事记（草稿）第二次国内革命战争'
        self.assertEqual('福建', extract_geo(s))


    def test_extract_6(self):
        s = '中共广丰县党史大事记（1993-2002）第二卷'
        self.assertEqual('二', extract_phase(s))
        s = '中共浚县党史大事记1949.10-1985.12（下编）'
        self.assertEqual('下', extract_phase(s))
        s = '中共漯河党史大事记下编1949-1992'
        self.assertEqual('下', extract_phase(s))
        s = '中共南乐县党史大事记（1926.10 - 1949.10）(上)'
        self.assertEqual('上', extract_phase(s))
        s = '中共平远县党史大事记新民主主义革命时期1925-1949第三稿'
        self.assertEqual('三', extract_phase(s))

    def test_extract_7(self):
        s = '中共太康县社会主义时期党史大事记1949.10-1985.12征求意见稿'
        self.assertEqual('太康', extract_geo(s))
        self.assertEqual('1949', extract_d1(s))
        self.assertEqual('1985', extract_d2(s))
    def test_extract_8(self):
        s = '中共遂溪县党史大事记一九二一-一九四九'
        self.assertEqual('1921', extract_d1(s))
        self.assertEqual('1949', extract_d2(s))
if __name__ == '__main__':
    unittest.main()
